<?php

namespace app\api\controller\v2;

use app\common\controller\Frontend;
use think\facade\Db;

class OpenArea extends Frontend
{

    protected array $noNeedLogin = ['*'];
    protected array $noNeedPermission = ['*'];

    #获取开通城市
    public function area ()
    {
        $name = $this->request->param('name');
        $where = [];
        if (!empty($name)) {
            $where[] = ['a.name', 'like', "%{$name}%"];
        }

        $ret = Db::name('platform_area')
            ->alias('p')
            ->join('ba_area a', 'p.city_id = a.id')
            ->where($where)
            ->where('p.status', 1)
            ->field('p.city_id,a.name')
            ->select();
        $this->success('获取成功', $ret);
    }
}
